/*Class that is an hex Cell*/

Cell = function(){
	//variables
	this.drawedObject;//an Array
	//drawedObject 
	//0->tile
	//1,2,3,4,5,6->overtiles
	//7->monster
	//8->building
	this.x;
	this.y;
}

//Specific getters and setters
Cell.prototype.setTile = function(aTile){
	this.drawedObject[0] = aTile;
}
Cell.prototype.getTile = function(){
	return this.drawedObject[0];
}
Cell.prototype.setOverTiles = function(overtiles){
	for (var i in overtiles){
		if (i < 6) {this.drawedObject[i+1] = overtiles[i];}
		else{console.log("ERROR : Too much overtiles in Cell");}
	}
}
Cell.prototype.getOverTiles = function(){
	return this.drawedObject.slice(1,7);
}
Cell.prototype.setMonster = function(aMonster){
	this.drawedObject[7] = aMonster;
}
Cell.prototype.getMonster = function(){
	return this.drawedObject[7];
}
Cell.prototype.setBuilding = function(aBuilding){
	this.drawedObject[8] = aBuilding;
}
Cell.prototype.getBuilding = function(){
	return this.drawedObject[8];
}

//constructor
Cell.prototype.initialize = function(ctx, aCellArray, coods){
	console.log("Cell start initializing.");
	//TO DO change this useless and lot of memory consumption
	this.drawedObject = new Array();//=[tile,..]
	this.x = coods[0];
	this.y = coods[1];
	var tile = new Tile();
	tile.initialize(ctx, aCellArray[0]);
	this.setTile(tile);//aCellArray[0] is a [x,y] with y index and x library index
	
	/*TO DO...
	for (var i=1;i<7;i++){
			drawedObject[i] = new overTile(ctx, aCellArray[i])
	}
	this.setMonster(new Monster(ctx, aCellArray[7]));
	this.setBuilding(new Building(ctx, aCellArray[8]));
	*/
	console.log("Cell finish initializing.");
}

Cell.prototype.draw = function(){
        var drawedObject = this.drawedObject;
        var x = this.x;
        var y = this.y;
        for (var i in drawedObject){
               drawedObject[i].draw(x,y);
        }
}